home *** CD-ROM | disk | FTP | other *** search
/ boe.pres.k12.wv.us / boe.pres.k12.wv.us.zip / boe.pres.k12.wv.us / Utilities / Xerox Workcentre 5335 / Windows Utilities / Font Management Utility / ChineseS / Xerox Font Management Utility.msi / Data1.cab / fmu.chm3 / skinsupport / madcapaliasfile.js < prev    next >
Text File  |  2011-04-21  |  4KB  |  195 lines

  1. // {{MadCap}} //////////////////////////////////////////////////////////////////
  2. // Copyright: MadCap Software, Inc - www.madcapsoftware.com ////////////////////
  3. ////////////////////////////////////////////////////////////////////////////////
  4. // <version>6.1.0.0</version>
  5. ////////////////////////////////////////////////////////////////////////////////
  6.  
  7. /* -CatapultCompiler- -Begin- -Copy to CSH Javascript- */
  8.  
  9. //
  10. //    Class CMCAliasFile
  11. //
  12.  
  13. function CMCAliasFile( xmlFile, helpSystem )
  14. {
  15.     // Private member variables
  16.  
  17.     var mXmlDoc        = null;
  18.     var mHelpSystem    = helpSystem;
  19.     var mNameMap    = null;
  20.     var mIDMap        = null;
  21.  
  22.     // Public properties
  23.  
  24.     // Constructor
  25.  
  26.     (function()
  27.     {
  28.         mXmlDoc = CMCXmlParser.GetXmlDoc( xmlFile, false, null, null );
  29.     })();
  30.  
  31.     // Public member functions
  32.     
  33.     this.GetIDs    = function()
  34.     {
  35.         var ids    = new Array();
  36.         
  37.         AssureInitializedMap();
  38.  
  39.         mIDMap.ForEach( function( key, value )
  40.         {
  41.             ids[ids.length] = key;
  42.             
  43.             return true;
  44.         } );
  45.         
  46.         return ids;
  47.     };
  48.     
  49.     this.GetNames    = function()
  50.     {
  51.         var names    = new Array();
  52.         
  53.         AssureInitializedMap();
  54.  
  55.         mNameMap.ForEach( function( key, value )
  56.         {
  57.             names[names.length] = key;
  58.             
  59.             return true;
  60.         } );
  61.         
  62.         return names;
  63.     };
  64.  
  65.     this.LookupID    = function( id )
  66.     {
  67.         var found    = false;
  68.         var topic    = null;
  69.         var skin    = null;
  70.  
  71.         if ( id )
  72.         {
  73.             if ( typeof( id ) == "string" && id.indexOf( "." ) != -1 )
  74.             {
  75.                 var pipePos    = id.indexOf( "|" );
  76.  
  77.                 if ( pipePos != -1 )
  78.                 {
  79.                     topic = id.substring( 0, pipePos );
  80.                     skin = id.substring( pipePos + 1 );
  81.                 }
  82.                 else
  83.                 {
  84.                     topic = id;
  85.                 }
  86.             }
  87.             else
  88.             {
  89.                 var mapInfo    = GetFromMap( id );
  90.                 
  91.                 if ( mapInfo != null )
  92.                 {
  93.                     found = true;
  94.                     topic = mapInfo.Topic;
  95.                     skin = mapInfo.Skin;
  96.                 }
  97.             }
  98.         }
  99.         else
  100.         {
  101.             found = true;
  102.         }
  103.  
  104.         if ( !skin )
  105.         {
  106.             if ( mXmlDoc )
  107.             {
  108.                 skin = mXmlDoc.documentElement.getAttribute( "DefaultSkinName" );
  109.             }
  110.         }
  111.         
  112.         if ( topic )
  113.         {
  114.             topic = mHelpSystem.ContentFolder + topic;
  115.         }
  116.         
  117.         return { Found: found, Topic: topic, Skin: skin };
  118.     };
  119.  
  120.     // Private member functions
  121.     
  122.     function GetFromMap( id )
  123.     {
  124.         var mapInfo    = null;
  125.         
  126.         AssureInitializedMap();
  127.  
  128.         if ( mNameMap != null )
  129.         {
  130.             if ( typeof( id ) == "string" )
  131.             {
  132.                 mapInfo = mNameMap.GetItem( id );
  133.                 
  134.                 if ( mapInfo == null )
  135.                 {
  136.                     mapInfo = mIDMap.GetItem( id );
  137.                 }
  138.             }
  139.             else if ( typeof( id ) == "number" )
  140.             {
  141.                 mapInfo = mIDMap.GetItem( id.toString() );
  142.             }
  143.         }
  144.  
  145.         return mapInfo;
  146.     }
  147.     
  148.     function AssureInitializedMap()
  149.     {
  150.         if ( mNameMap == null )
  151.         {
  152.             if ( mXmlDoc )
  153.             {
  154.                 mNameMap = new CMCDictionary();
  155.                 mIDMap = new CMCDictionary();
  156.                 
  157.                 var maps    = mXmlDoc.documentElement.getElementsByTagName( "Map" );
  158.  
  159.                 for ( var i = 0; i < maps.length; i++ )
  160.                 {
  161.                     var topic    = maps[i].getAttribute( "Link" );
  162.                     var skin    = maps[i].getAttribute( "Skin" );
  163.                     
  164.                     if ( skin )
  165.                     {
  166.                         skin = skin.substring( "Skin".length, skin.indexOf( "/" ) );
  167.                     }
  168.                     
  169.                     var currMapInfo    = { Topic: topic, Skin: skin };
  170.                     
  171.                     var name    = maps[i].getAttribute( "Name" );
  172.                     
  173.                     if ( name != null )
  174.                     {
  175.                         mNameMap.Add( name, currMapInfo );
  176.                     }
  177.                     
  178.                     var resolvedId    = maps[i].getAttribute( "ResolvedId" );
  179.                     
  180.                     if ( resolvedId != null )
  181.                     {
  182.                         mIDMap.Add( resolvedId, currMapInfo );
  183.                     }
  184.                 }
  185.             }
  186.         }
  187.     }
  188. }
  189.  
  190. //
  191. //    End class CMCAliasFile
  192. //
  193.  
  194. /* -CatapultCompiler- -End- -Copy to CSH Javascript- */
  195.